Don't do anything if the two windows are the same.
authorRichard Hult <richard@imendio.com>
Wed, 6 Jun 2007 16:23:50 +0000 (16:23 +0000)
committerRichard Hult <rhult@src.gnome.org>
Wed, 6 Jun 2007 16:23:50 +0000 (16:23 +0000)
2007-06-06  Richard Hult  <richard@imendio.com>

* gdk/quartz/gdkevents-quartz.c (get_converted_window_coordinates):
Don't do anything if the two windows are the same.
(find_window_for_ns_event): Translate coordinates to be relative
the grab window when appropriate.

svn path=/trunk/; revision=18064

ChangeLog
gdk/quartz/gdkevents-quartz.c

index 96aa053ef1e277e470be9c8c1615c485c4ebd294..9b0a0f0ce236824588f7aa6bdac5bc8c7e80374a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-06-06  Richard Hult  <richard@imendio.com>
+
+       * gdk/quartz/gdkevents-quartz.c (get_converted_window_coordinates):
+       Don't do anything if the two windows are the same.
+       (find_window_for_ns_event): Translate coordinates to be relative
+       the grab window when appropriate.
+
 2007-06-06  Emmanuele Bassi  <ebassi@gnome.org>
 
        * gtk/gtkfilechooserdefault.c:
index ae58307b798705e63fe1103915659aa5dc55e4d1..8d0e9439ee76a10d1359697df29cbbb8d6c335ea 100644 (file)
@@ -905,6 +905,13 @@ get_converted_window_coordinates (GdkWindow *in_window,
   int in_origin_x, in_origin_y;
   int out_origin_x, out_origin_y;
 
+  if (in_window == out_window)
+    {
+      *out_x = in_x;
+      *out_y = in_y;
+      return;
+    }
+
   /* First translate to "in" toplevel coordinates, then on to "out"
    * toplevel coordinates, and finally to "out" child (the passed in
    * window) coordinates.
@@ -1077,26 +1084,29 @@ find_window_for_ns_event (NSEvent *nsevent,
                  return real_window;
              }
 
-           /* FIXME: This part needs some fixing, it doesn't return
-            * the right coordinates if the nsevent happens for a
-            * different window than the grab window.
-            */
+           /* Finally check the grab window. */
            if (pointer_grab_event_mask & get_event_mask_from_ns_event (nsevent))
              {
+                GdkWindow *event_toplevel;
                GdkWindow *grab_toplevel;
                NSPoint point;
                int x_tmp, y_tmp;
 
+                event_toplevel = [(GdkQuartzView *)[[nsevent window] contentView] gdkWindow];
                grab_toplevel = gdk_window_get_toplevel (_gdk_quartz_pointer_grab_window);
                point = [nsevent locationInWindow];
 
                x_tmp = point.x;
                y_tmp = GDK_WINDOW_IMPL_QUARTZ (GDK_WINDOW_OBJECT (grab_toplevel)->impl)->height - point.y;
 
-               get_child_coordinates_from_ancestor (grab_toplevel,
-                                                    x_tmp, y_tmp, 
-                                                    _gdk_quartz_pointer_grab_window,
-                                                    x, y);
+                /* Translate the coordinates so they are relative to
+                 * the grab window instead of the event toplevel for
+                 * the cases where they are not the same.
+                 */
+                get_converted_window_coordinates (event_toplevel,
+                                                  x_tmp, y_tmp,
+                                                  _gdk_quartz_pointer_grab_window,
+                                                  x, y);
 
                return _gdk_quartz_pointer_grab_window;
              }